package com.ebelter.bpm.activitys;



import android.content.Intent;
import android.view.View;
import com.ebelter.bpm.R;
import com.ebelter.bpm.common.Constant;
import com.ebelter.btcomlib.bases.activity.BaseActivity;
import com.ebelter.btcomlib.common.Constants;
import com.ebelter.btcomlib.utils.SpUtil;
import com.ebelter.btcomlib.utils.UserSpUtil;
import com.ebelter.btcomlib.utils.log.LogUtils;

public class BPM_SplashActivity extends BaseActivity {

    public static final String TAG="BPM_SplashActivity";


    @Override
    protected int loadLayoutById() {
        return R.layout.activity_bpm_splash;
    }


    @Override
    protected void initData() {

        if((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0){
            LogUtils.i(TAG,"----splash---进入了getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0 界面退出" );
            finish();
            return;
        }
        boolean isFirstOpen = SpUtil.readBoolean(Constant.IBpm.IS_FIRST_OPEN,true);//判断是否第一次打开app
        if (!isFirstOpen){
            //如果不是第一次打开这个app就直接进入登录界面
            //先判断是否登录了 如果登录了直接打开主页面 如果没有登录就跳转到登录界面
            long userid = UserSpUtil.readLong(Constants.IUser.USER_ID);
            if (userid<=0){
                startActivity(BPM_LoginActivity.class);
            }else {
                startActivity(BPMMainActivity.class);
            }
            finish();
        }else {
            SpUtil.writeBoolean(Constant.IBpm.IS_FIRST_OPEN,false);//记录一下状态
        }




    }

    //跳转到注册界面
    public void bt_join_bpm_splash(View view){
        LogUtils.i(TAG,"BPM_SplashActivity---bt_join_bpm_splash");
        startActivity(BPM_RegisterActivity.class);

    }


    //跳转到登录界面
    public void bt_sign_bpm_splash(View view){
        LogUtils.i(TAG,"BPM_SplashActivity---bt_sign_bpm_splash");
        startActivity(BPM_LoginActivity.class);

    }
}
